<?php

class AdminModel extends Model {
	public static function ulist($page = 1, $pagesize = 20)
	{
		$page = intval($page);
		$page = $page ? $page : 1;
		$pagesize = intval($pagesize);
		$pagesize = $pagesize ? $pagesize : 20;
		
		$recordcount = daocall("admin", "nusers", null);
		if(!$recordcount) return array();

		$users = array();
		$uids = daocall("admin", "ulist", array($page, $pagesize));
		if($uids)
		{
			foreach($uids as $row)
			{
				$uid = $row["uid"];
				$uinfo = daocall("user", "getuser", array($uid));
				if ($uinfo)
				{
					$users[$uid]["base"] = $uinfo;
					$users[$uid]["base"]["uid"] = $uid;
				}

				$uinfo = daocall("user", "getuserext", array($uid));
				if ($uinfo) $users[$uid]["ext"] = $uinfo;
			}
		}

		return $users;
	}
}
?>